#include "pubsub.h"

#include <fmt/core.h>
#include <stdlib.h>

#include <QMutex>

Pubsub* Pubsub::pubusb_self = nullptr;

Pubsub::Pubsub() {
    this->log = LogUtil::getLogger("pubsub");
}

Pubsub* Pubsub::getInstance() {
    if (pubusb_self == NULL) {
        static QMutex mutex;

        QMutexLocker locker(&mutex);

        if (pubusb_self == NULL) {
            pubusb_self = new Pubsub;
        }
    }

    return pubusb_self;
}

void Pubsub::publish(const JannaTopic& topic, const QMap<QString, QVariant>& param) {
    emit signalPublish(topic, param);
}
